package com.jinkeen.xiaxie.pictureInPicture

import android.app.Presentation
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.Display
import com.jinkeen.xiaxie.R

/**
 * display  需要显示的屏幕
 * outerContext 不是activity的context是与display绑定的context，用于加载资源使用
 * width:480 height:1920 density:1.3312501 使用drawable-hdpi的图片
 **/
class SecondPresentation(context: Context, display: Display) : Presentation(context, display) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        //getWindow()?.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        //getWindow()?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        //display.
        //getWindow()?.setType(WindowManager.LayoutParams.TYPE_APPLICATION);

        setContentView(R.layout.layout_second_screen)//副屏显示的布局

        //findViewById<ImageView>(R.id.img).setImageResource(R.drawable.img1)

        window?.decorView?.post {
            /*var layout1 = findViewById<FrameLayout>(R.id.layout_1)
            Log.i(
                "ZZZZ",
                "x:${layout1.x} y:${layout1.y} width:${layout1.width} height:${layout1.height}"
            )*/

            /*val lp = layout1.layoutParams as FrameLayout.LayoutParams
            layout1.x = 100F
            layout1.y = 100F
            layout1.rotationX = 90F
            layout1.postInvalidate()*/

            /*val rotation: ObjectAnimator =
                ObjectAnimator.ofFloat(layout1, "rotation", 0f, 90f)
            //objectAnimator.duration = 0
            //objectAnimator.start()

            val translationX: ObjectAnimator =
                ObjectAnimator.ofFloat(layout1, "translationX", 0f, -720F)

            val translationY: ObjectAnimator =
                ObjectAnimator.ofFloat(layout1, "translationY", 0f, 720F)
            //objectAnimator2.duration = 0
            //objectAnimator2.start()

            val animatorSet = AnimatorSet();
            animatorSet.playSequentially(rotation, translationX, translationY)
            animatorSet.duration = 0
            animatorSet.start()*/

            /*val objectAnimator1 = ObjectAnimator.ofArgb(layout1, "rotate", Color.WHITE, Color.GREEN);
            val objectAnimator2 = ObjectAnimator.ofFloat(layout1, "scaleX", 0.1f, 1.2f);
            val objectAnimator3 = ObjectAnimator.ofFloat(layout1, "scaleY", 0.5f, 1.0f);
            val objectAnimator4 = ObjectAnimator.ofFloat(layout1, "translationY", 0, 250);

            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(objectAnimator1,objectAnimator2,objectAnimator3,objectAnimator4);
            animatorSet.setDuration(3000);
            animatorSet.start();*/
        }
    }

    override fun onStart() {
        super.onStart()
        Log.i("ZZZZ", "onStart")
    }


    //消失时调用
    override fun onStop() {
        super.onStop()
        Log.i("ZZZZ", "onStop")
    }
}
